package com.atguigu.gmall.publisherlj.mapper;

import com.atguigu.gmall.publisherlj.bean.TradeStats;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @Author 晶晶  写sql
 * @Date 2023 03 29 18 56
 **/
public interface TradeStatisticsMapper {

    @Select("select\n" +
            " sum(user_order_count) order_total_amount\n" +
            " from dws_trade_statistics\n" +
            " where toYYYYMMDD(stt) =#{date}\n" +
            " group by toYYYYMMDD(stt)")
    BigDecimal selectOrderAmount(int date);

    @Select("select\n" +
            " '下单人次' type,\n" +
            "  count(order_count) value\n" +
            "  from dws_trade_statistics\n" +
            "  where toYYYYMMDD(stt) =#{date}\n" +
            " union all\n" +
            "  select\n" +
            "  '下单人数' type,\n" +
            "  count(user_order_count) value\n" +
            "  from dws_trade_statistics\n" +
            "  where toYYYYMMDD(stt) =#{date}")
    List<TradeStats> selectTradeStats(int date);
}
